package com.itao.config.toml;

import com.alibaba.fastjson2.JSON;
import com.moandjiezana.toml.Toml;

import java.io.InputStream;
import java.util.Map;

/**
 * @Author sjt
 * @CreateTime 2024/6/6 14:33:51
 */
public class TomlConfig {
    private static final InputStream is;

    static {
        String path = "Cargo.toml";
        is = TomlConfig.class.getClassLoader().getResourceAsStream(path);
    }

    public static void main(String[] args) {
        // 创建TOML实例
        Toml toml = new Toml();

        // 读取TOML文件
        toml.read(is);

        // 将解析结果封装成Map
        Map<String, Object> map = toml.toMap();
        String jsonString = JSON.toJSONString(map);
        System.out.println(JSON.parseObject(jsonString, TomlEntity.class));
    }
}
